home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 1021 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.8 KB

  1. From: Adel El-Beik <A.El-Beik@man0506.wins.icl.co.uk>
  2. Message-ID: <4ke06a$rp3@mozart.wg.icl.co.uk>
  3. X-Original-Date: 9 Apr 1996 15:36:42 GMT
  4. Path: in1.uu.net!bounce-back
  5. Date: 10 Apr 96 11:18:50 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: Array function params and const qualifier
  9. Organization: ICL
  10. X-Mailer: Mozilla 1.1N (Windows; I; 16bit)
  11. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  12.     iQBFAgUBMWuZIeEDnX0m9pzZAQGdpgF+JUYLXnHvQWNSfdjRjztiDQSmzyB2Y3+F
  13.     YffEAs2B3d4MM6tBSYyOfJ142kn7ZrHZ
  14.     =md8j
  15.  
  16. I have a question concerning MSVC++ v.4.00 and the April DWP C++.
  17.  
  18. The following code fails on MSVC++.  It doesn't like line labelled 1.
  19. It complains with 
  20.  
  21. C:\array\array.cpp(16) : error C2664: 'func' : cannot convert parameter 1 
  22. from 'long [2][2]' to 'const long [][2]' (new behavior; please see help)
  23.  
  24. Now as far as I can understand from DWP an implicit conversion should
  25. take place on x. i.e. it is const qualified, and so MSVC++ should not 
  26. raise an error.  MSVC++ accepts line labelled 2, which should be
  27. what MSVC++ converts the funcion argument and parameter to on 1.
  28.  
  29. Is their something I've missed, i.e. MSVC++ behaviour matches April
  30. DWP ?  Or is MSVC++ followed its own standard, Microsoft claim to
  31. be following evolving standard.
  32.  
  33. Thanks in advance.
  34.  
  35. Adel.
  36.  
  37. // CODE START
  38.  
  39.  
  40. typedef long bar[2][2];
  41. typedef const long (*const_bar)[2];
  42.  
  43.  
  44. void func( const bar param ){}
  45.  
  46.  
  47.  
  48. void main()
  49. {
  50.     bar x;
  51.     
  52.     func( x );               // 1
  53.  
  54.     func( (const_bar)x );    // 2
  55. }
  56.  
  57. // CODE END
  58. ---
  59. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  60. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  61. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  62. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  63. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  64.